﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CustomizeSanPham : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void btnCustomize_Click(object sender, EventArgs e)
    {
        GioHangBUS objShoppingCart;
        GioHangDTO shoppingCartDto;
        if (!txtCpu.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtCpu_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtMainboard.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtMainboard_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtHdd.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtHdd_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtRam.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtRam_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtVga.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtVga_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtMonitor.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtMonitor_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtCd.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtCd_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtHdh.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtHdh_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtKeyboard.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtKeyboard_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtSpeaker.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtSpeaker_hidden.Value);
            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtCase.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtCase_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
        if (!txtPower.Text.Equals(""))
        {
            // Add the product to the shopping cart
            objShoppingCart =
                new GioHangBUS(TGDDConfiguration.DbConnectionString);
            shoppingCartDto = new GioHangDTO();
            shoppingCartDto.Id = AccessGioHang.idGioHang;
            shoppingCartDto.IdSanPham = int.Parse(txtPower_hidden.Value);

            try
            {
                // Execute the insert command
                bool success = objShoppingCart.AddItemToGioHang(shoppingCartDto);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }


    }
}
